﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections;

public partial class admin_statistics_sDown : System.Web.UI.Page
{
    public string java = "";
    public string net = "";
    public string db = "";
    public string other = "";
    public string count = "";
    public string time1 = "";
    public string time2 = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        Server.Execute("../inc/checkPurview.aspx");  // 此处用户权限验证

        Chartlet1.AppearanceStyle = FanG.Chartlet.AppearanceStyles.Bar_2D_StarryNight_FlatCrystal_Glow_NoBorder;
        Chartlet1.Fill.ShiftStep = 8;
        Chartlet1.Crystal.Contraction = 0;
        Chartlet1.Shadow.Distance = 20;
        Chartlet1.Shadow.Alpha = 100;
        Chartlet1.XLabels.UnitText = "类型";
        Chartlet1.YLabels.UnitText = "次数";
        Chartlet1.Width = 600;
        Chartlet1.Height = 400;
        ArrayList aLabel = new ArrayList();
        aLabel.Add("Java课件");
        aLabel.Add(".net课件");
        aLabel.Add("数据库课件");
        aLabel.Add("其他课件");

        ArrayList dataList = new ArrayList();
        dataList.Add(0);
        dataList.Add(0);
        dataList.Add(0);
        dataList.Add(0);

        ArrayList ColorGuider = new ArrayList();
        ColorGuider.Add("下载次数");

        ArrayList[] dataL = { dataList };
        Chartlet1.ChartTitle.Text = "课件下载次数统计\n\r";

        Chartlet1.InitializeData(dataL, aLabel, ColorGuider);
    }
    protected void btn_ok_Click(object sender, EventArgs e)
    {
        db_courseware cw = new db_courseware();
        time1 = tb_time_1.Text;
        time2 = tb_time_2.Text;
        DataSet ds = cw.statisticsDown("1", time1, time2);
        if (ds.Tables[0].Rows.Count != 0)
        {
            java = ds.Tables[0].Rows[0]["num"].ToString();
        }
        else
        {
            java = "0";
        }
        ds = cw.statisticsDown("2", time1, time2);
        if (ds.Tables[0].Rows.Count != 0)
        {
            net = ds.Tables[0].Rows[0]["num"].ToString();
        }
        else
        {
            net = "0";
        }
        ds = cw.statisticsDown("3", time1, time2);
        if (ds.Tables[0].Rows.Count != 0)
        {
            db = ds.Tables[0].Rows[0]["num"].ToString();
        }
        else
        {
            db = "0";
        }
        ds = cw.statisticsDown("4", time1, time2);
        if (ds.Tables[0].Rows.Count != 0)
        {
            other = ds.Tables[0].Rows[0]["num"].ToString();
        }
        else
        {
            other = "0";
        }
        try
        {
            count = (Int32.Parse(java) + Int32.Parse(net) + Int32.Parse(db) + Int32.Parse(other)).ToString();
        }
        catch
        {
            count = "";
        }

        ArrayList aLabel = new ArrayList();
        aLabel.Add("Java课件");
        aLabel.Add(".net课件");
        aLabel.Add("数据库课件");
        aLabel.Add("其他课件");

        ArrayList dataList = new ArrayList();
        dataList.Add(java);
        dataList.Add(net);
        dataList.Add(db);
        dataList.Add(other);


        ArrayList[] dataL = { dataList };

        Chartlet1.ChartTitle.Text = time1 + " ~ " + time2 + " 课件下载次数统计\n\r";
        ArrayList ColorGuider = new ArrayList();
        ColorGuider.Add("下载次数");

        Chartlet1.InitializeData(dataL, aLabel, ColorGuider);
    }
}